package com.hopes.bizz.close.gis.vo;

import com.hopes.bizz.close.common.constant.enums.ParkCloseSysDictEnum;
import com.hopes.bizz.close.visitor.entity.ClosedGeneralCarRecordEntity;
import com.hopes.bizz.close.visitor.entity.ClosedHazardCarRecordEntity;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import lombok.Data;
import org.jetbrains.annotations.NotNull;

import java.io.Serializable;
import java.util.Date;

/**
 * @author yumr
 * @ProjectName bizz
 * @Description 卡口通行记录VO
 * @time 2024/2/25 15:03
 */
@Data
public class GateRecordVO implements Comparable<GateRecordVO>, Serializable {

    private static final long serialVersionUID = -7967997525184040951L;

    private Long id;

    private String type;

    private Long orgId;

    private String carId;

    private String licencePlateNumber;

    private String carOwnerName;

    private String carOwnerPhone;

    private Date inOutTime;

    private Integer direction;


    public GateRecordVO(ClosedHazardCarRecordEntity hazardCarRecord) {
        this.type = "hazard";
        this.id = hazardCarRecord.getId();
        this.orgId = hazardCarRecord.getOrgId();
        this.inOutTime = hazardCarRecord.getInOutTime();
        this.direction = hazardCarRecord.getDirection();
        this.carOwnerName = hazardCarRecord.getCarOwnerName();
        this.carOwnerPhone = hazardCarRecord.getCarOwnerPhone();
        this.licencePlateNumber = hazardCarRecord.getLicencePlateNumber();
    }


    public GateRecordVO(ClosedGeneralCarRecordEntity generalCarRecord) {
        this.type = "general";
        this.id = generalCarRecord.getId();
        this.orgId = generalCarRecord.getOrgId();
        this.inOutTime = generalCarRecord.getInOutTime();
        this.direction = generalCarRecord.getDirection();
        this.carOwnerName = generalCarRecord.getCarOwnerName();
        this.carOwnerPhone = generalCarRecord.getCarOwnerPhone();
        this.licencePlateNumber = generalCarRecord.getLicencePlateNumber();
    }

    public String getOrgIdStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_company, this.getOrgId());
    }

    public String getDirectionStr() {
        return DictResolver.getItemLabelByValue(ParkCloseSysDictEnum.close_visitor_record_direction_type, this.getDirection());
    }

    @Override
    public int compareTo(@NotNull GateRecordVO o) {
        return o.inOutTime.compareTo(this.inOutTime);
    }
}
